package com.example.car.manager.utils;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;

import com.example.car.R;
import com.example.car.manager.BaseActivity;

public class FullDialog extends Dialog {
	
	public FullDialog(Context context, int theme) {
		super(context, theme);
		activity=(BaseActivity)context;
		setFullScreen();
	}

	public BaseActivity activity;

	protected FullDialog(Context context, boolean cancelable,
			OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
	
	}

	public FullDialog(Context context) {
		
		super(context);
	}
	private void setFullScreen() {
		LayoutParams lay = getWindow().getAttributes();
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		Rect rect = new Rect();
		View view = getWindow().getDecorView();
		view.getWindowVisibleDisplayFrame(rect);
		lay.height = dm.heightPixels - rect.top;
		lay.width = dm.widthPixels;
		lay.gravity = Gravity.CENTER;
		getWindow().setAttributes(lay);
	}
	
	public void  intiView(View v,String tiltle){
		v.findViewById(R.id.title_back_btn).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		
	((TextView)v.findViewById(R.id.title_rightbtn1)).setText(tiltle);;	
	}
}
